﻿import { Component, EventEmitter, Injector, Output, ViewChild } from '@angular/core';
import { AppComponentBase } from '@shared/common/app-component-base';
import { PasswordComplexitySetting, ProfileServiceProxy, UserEditDto, UserServiceProxy, UsingFormDetailDto } from '@shared/service-proxies/service-proxies';
import { ModalDirective } from 'ngx-bootstrap';
import { finalize } from 'rxjs/operators';
import { TestDataDto, UsingFormServiceProxy,UsingFormState, UsingFormDetailExeInput } from '@shared/service-proxies/service-proxies';
import * as moment from 'moment';
@Component({
    selector: 'requirementgetaudit2rejecteditcomponent',
    templateUrl: './requirement-get-audit2_reject_edit.component.html',
    styles: [`.user-edit-dialog-profile-image {
             margin-bottom: 20px;
        }`
    ]
})
export class Requirementgetaudit2rejecteditcomponent extends AppComponentBase {
    @ViewChild('createOrEditModal') modal: ModalDirective;
    @Output() modalSave: EventEmitter<any> = new EventEmitter<any>();

    active = false;
    saving = false;
    user: UserEditDto = new UserEditDto();
    input: UsingFormDetailExeInput = new UsingFormDetailExeInput();

    profilePicture: string;
    fieldDate:Date;
    quantity: number;
    originalQuantity: number;
    
    constructor(
        injector: Injector,
        private _usingFormServiceProxy: UsingFormServiceProxy
    ) {
        super(injector);
    }
    /**
     * 需求投产
     * @param requirementsForPartsDetailDto 
     */
    onShown(): void {
        
    }
    /**
     * 需求投产和编辑投产
     */
    save(): void {
        this.saving = true;
            this._usingFormServiceProxy.backToCreation(this.input)
            .pipe(finalize(() => { this.saving = false; }))
            .subscribe(() => {
                this.notify.info(this.l('SavedSuccessfully'));
                this.close();
                this.modalSave.emit(null);
            });
    }

    show(record?:UsingFormDetailDto):void{
        this.input.id = record.id;
        this.active=true;
        this.modal.show();
    }
    /**
     * 关闭窗口
     */
    close(): void {
        this.active = false;
        this.modal.hide();
    }
}
